package com.github.leecho.spring.cloud.gateway.dubbo.argument.rewirte.variable;

import lombok.Getter;
import org.springframework.web.server.ServerWebExchange;

import java.util.HashMap;
import java.util.Map;

/**
 * @author LIQIU
 * @date 2021/7/26 17:16
 */
public class DefaultVariableRenderContext implements VariableRenderContext {

	@Getter
	private final ServerWebExchange exchange;

	@Getter
	private final Map<String, Object> payload;

	@Getter
	private Map<String, Object> variables = new HashMap<>();

	public DefaultVariableRenderContext(ServerWebExchange exchange,
										Map<String, Object> payload) {
		this.exchange = exchange;
		this.payload = payload;
	}

	@Override
	public void setVariable(String name, Object value) {
		variables.put(name, value);
	}

	public void setVariables(Map<String, Object> variables) {
		this.variables = variables;
	}
}
